package com.example.villagedevelop.generator.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.villagedevelop.generator.entity.Case0;
import com.example.villagedevelop.generator.entity.CaseVO;
import com.example.villagedevelop.generator.entity.Develop;
import com.example.villagedevelop.generator.entity.ImageCase;
import com.example.villagedevelop.generator.mapper.CaseMapper;
import com.example.villagedevelop.generator.mapper.ImageCaseMapper;
import com.example.villagedevelop.generator.service.CaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author villagedevelop
 * @since 2021-11-13
 */
@RestController
@RequestMapping("/case")
public class CaseController {

    @Autowired
    CaseService caseService;
    @Autowired
    CaseMapper caseMapper;
    @Autowired
    ImageCaseMapper imageCaseMapper;

    //返回所有数据（不分页）,未返回VO，不包括照片
    @GetMapping("/visitall")
    public List<Case0> findAll(){
        return caseService.list();
    }

    //分页查询返回数据
    @GetMapping("/visit/{page}")
    public List<CaseVO> findList(@PathVariable("page") int current){
        return caseService.findCaseVOByPage(current);
    }


    @PostMapping("/save")
    public void save(@RequestBody CaseVO caseVO){
        caseService.insertCaseVO(caseVO);
    }

    @PostMapping("/modify")
    public void modify(@RequestBody Case0 case0){
        caseMapper.updateById(case0);
    }



}

